import math


def decimal_to_hex(decimal_number) -> str:
    """
    十进制转16进制
    :param decimal_number:
    :return:
    """
    hex_string = hex(decimal_number)
    return "0" * (8 - len(hex_string[2:])) + hex_string[2:]


class CoordinateConverter:
    """经纬度转cat62"""
    def __init__(self, lat, lon):
        self.latitude = lat
        self.longitude = lon

    def convert_to_cat62(self):
        total_divisions = pow(2, 25)
        lat_fraction = math.ceil((self.latitude + 90) * total_divisions / 180)
        lon_fraction = math.ceil((self.longitude + 180) * total_divisions / 360)

        return lat_fraction, lon_fraction


if __name__ == '__main__':
    # 调用示例

    lat = 37.7749
    lon = -122.4194
    print(math.ceil(lat))

    converter = CoordinateConverter(lat, lon)
    cat62_value = converter.convert_to_cat62()
    print(cat62_value)  # 输出：CAT62: 8523031, 5062829
    for i in cat62_value:
        print(decimal_to_hex(i))

